<template>
	<view>
		<view class="selectOne">
			<text>所在场区</text>
			<view class="selectOneContent">
				 <uni-data-select
				        v-model="value"
				        :localdata="detpList"
				        @change="change(value)"
				      ></uni-data-select>
			</view>

		</view>
		<view class="bottons">
				<uni-segmented-control class="custom-segmented-control" :current="currentIndex" :values="iii" @clickItem="onClickItem" styleType="button" activeColor="#777"></uni-segmented-control>
		</view>
		<view v-show="currentIndex===0">
			<cardCompents v-for="(item,index) in SowList" :key="index"  :data="SowList[index]"></cardCompents>
		</view>
		<view v-show="currentIndex===1">
			你好
		</view>
		<!-- 猪只转舍 -->
		<view v-show="currentIndex===2">
			<cardTransfer v-for="(item,index) in dataInformation" :key="index"  :data="dataInformation[index]"></cardTransfer>
			<button class="transferBotton">新增</button>
		</view>
		<!-- 猪只死亡 -->
		<view v-show="currentIndex===3">
			<cardDeath v-for="(item,index) in dataInformation" :key="index"  :data="dataInformation[index]"></cardDeath>
		</view>
		<!-- 猪只称重 -->
		<view v-show="currentIndex===4">
			<cardWeigh v-for="(item,index) in dataInformation" :key="index"  :data="dataInformation[index]"></cardWeigh>
		</view>
	</view>


</template>

<script>
	import cardCompents from './cardCompents/cardCompents.vue';
	import cardTransfer from './cardCompents/cardTransfer.vue';
	import cardDeath from './cardCompents/cardDeath.vue';
	import cardWeigh from './cardCompents/cardWeigh.vue';
	import {getSow,getFactoryName} from '@/api/sow/sowInformation.js'
	export default {
		components:{
			cardCompents,
			cardTransfer,
			cardDeath,
			cardWeigh
		},
		data() {
			return {
				 
				value:-1,
				range: [],
				detpList:[],
				iii:["信息总览","关键计划","猪只转舍","猪只死亡","猪只称重"],
				currentIndex:0,
				dataInformation:[{
					code:11111,
					factoryName:"重庆",
					deptName:"肥猪",
					status:1,
					earCode:123,
					parity:2,
					remark:"为什么",
					createdTime:"2021-5-6",
					createdBy:"小黑子"
				},{
					code:222,
					factoryName:"重庆",
					deptName:"肥猪",
					status:1,
					earCode:123,
					parity:2,
					remark:"为什么",
					createdTime:"2021-5-6",
					createdBy:"小黑子"
				}],	
				SowList:[ 
				],
				SowQueryInformationReq:{
					pageSize:4,
					pageNum:1,
					FactoryID:this.value
				}
			};
		},
		methods: {
			change(e) {
				this.getSowInformation()
			},
			onClickItem(e) {
			     if (this.currentIndex != e.currentIndex) {
			       this.currentIndex = e.currentIndex;
			     }
			   },
			 getSowInformation() {
			     getSow(this.SowQueryInformationReq).then((res)=>{
					 console.log(res)
					 this.SowList=res.data.list
				 })
			},
			getFactory(){
				getFactoryName().then((res)=>{
					this.range=res.data
					console.log(res)
					this.detpList=this.range.map((item)=>{
						return {
							...item,
							text:item.deptName,
							value:item.deptId
						}
					})
				})
			}
		},
		created(){
			console.log('执行了')
			this.getSowInformation()
			this.getFactory()
		},
		
	};
</script>

<style>
	.selectOne {
		display: flex;
		width: 100%;
		justify-content: center;
		align-items: center;
	}

	.selectOneContent {
		width: 60%;
		border-color: black;
		margin-left: 10rpx;
	}

	.bottons {
		display: flex;
		width: 100%;
		justify-content: center;
		margin-top: 20rpx;
	}
 
   .custom-segmented-control{
	   border-radius: 50rpx;
	   font-size: 18rpx;
	   border:1px solid;
   }
</style>